﻿using System;
using System.Collections.Generic;
using System.Text;
using X.DataFactory;
using X.Entity;

namespace X.Bll
{
    public sealed class Product
    {
        private static readonly IProduct dal = DataAccess.CreateProduct();

        public static int Create(ProductInfo productInfo) { return dal.Create(productInfo); }
        public static bool Delete(int productId) { return dal.Delete(productId); }
        public static ProductInfo GetProduct(int productId) { return dal.GetProduct(productId); }
        public static ProductInfo GetProduct(string productName) { return dal.GetProduct(productName); }
        public static IList<ProductInfo> GetAllList() { return dal.GetAllList(); }
        public static IList<ProductInfo> GetList() { return dal.GetList(); }
        public static IList<ProductInfo> GetList(int topCount) { return dal.GetList(topCount); }
        public static IList<ProductInfo> GetHotList(int topCount) { return dal.GetHotList(topCount); }    //热销
        public static IList<ProductInfo> GetRecList(int topCount) { return dal.GetRecList(topCount); }    //推荐
        public static IList<ProductInfo> GetListByCategoryName(string categoryName) { return dal.GetListByCategoryName(categoryName); }
        public static IList<ProductInfo> GetListByCategoryId(int categoryId) { return dal.GetListByCategoryId(categoryId); }
        public static IList<ProductInfo> GetListByPrice(decimal lowPrice, decimal hightPrice) { return dal.GetListByPrice(lowPrice, hightPrice); }

        public static bool Update(ProductInfo productInfo) { return dal.Update(productInfo); }
        public static IList<ProductInfo> Search(string keyword) { return dal.Search(keyword); }
        public static void UploadImage(int productId, IList<string> list) { dal.UploadImage(productId, list); }
        public static void DeleteImage(int imageId) { dal.DeleteImage(imageId); }
        public static IList<string> GetImagesList(int productId) { return dal.GetImagesList(productId); }

        public static IList<PriceInfo> GetPriceList() { return dal.GetPriceList(); }
        public static bool CreatePrice(PriceInfo priceInfo) { return dal.CreatePrice(priceInfo); }
        public static bool UpdatePrice(PriceInfo priceInfo) { return dal.UpdatePrice(priceInfo); }
        public static bool DeletePrice(int id) { return dal.DeletePrice(id); }
        public static PriceInfo GetPriceInfo(int id) { return dal.GetPriceInfo(id); }

        public static IList<TagInfo> GetTagList() { return dal.GetTagList(); }
        public static IList<TagInfo> GetAllTagList() { return dal.GetAllTagList(); }
        public static TagInfo GetTagInfo(int tagId) { return dal.GetTagInfo(tagId); }
        public static bool UpdateTag(TagInfo tagInfo) { return dal.UpdateTag(tagInfo); }
    }

    public sealed class ProductCategory
    {
        private static readonly IProductCategory dal = DataAccess.CreateProductCategory();

        public static bool Create(ProductCategoryInfo category)
        { return dal.Create(category); }
        public static bool Delete(int categoryId)
        {
            return dal.Delete(categoryId);
        }
        public static ProductCategoryInfo GetCategory(int categoryId) { return dal.GetCategory(categoryId); }
        public static ProductCategoryInfo GetCategory(string categoryName) { return dal.GetCategory(categoryName); }
        public static IList<ProductCategoryInfo> GetList() { return dal.GetList(); }
        public static IList<ProductCategoryInfo> GetCategoryList() { return dal.GetCategoryList(); }
        public static IList<ProductCategoryInfo> GetNavList() { return dal.GetNavList(); }
        public static bool Update(ProductCategoryInfo categoryInfo) { return dal.Update(categoryInfo); }

        public static int GetProductCount(int categoryId) { return dal.GetProductCount(categoryId); }
    }
}
